home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / rkey15.zip / RKEY.DOC < prev    next >
Text File  |  1991-02-09  |  20KB  |  594 lines

  1.  
  2.  
  3.                   rKey 1.5 (c) 1990, 1991 Serious Cybernetics
  4.                      Turbo Pascal(tm) Registration Key Unit
  5.                                by C. Scott Davis
  6.  
  7.  
  8. -------------------------------------------------------------------------------
  9.  
  10.  
  11. rKey is a small and simple version of a Turbo Pascal (tm) Registration Key Unit
  12. (the enhanced version is RkPlus).  It is designed to provide the most basic
  13. handling of registration keys, with a minimum of memory usage. All of the key
  14. encryption, checking and key file routines are handled in rKey, requiring
  15. little effort on the part of the programmer.  It can allow anything from simple
  16. registration messages to limiting program functions if the software is not
  17. registered.
  18.  
  19.  
  20. There are two versions of rKey included here. RKEY.TPU, which runs under Turbo
  21. Pascal (tm) 5.5 and RKEY6.TPU, which runs under Turbo Pascal (tm) 6.0.  For
  22. enhanced registration key handling (such as multiple encryption strings,
  23. registration levels and limited use demo keys) you should obtain a copy of
  24. RkPlus.  The latest version of rKey and RkPlus (as well as other Serious
  25. Cybernetics software) are always available for download and Fido file request
  26. from Phoenix StarFighter BBS (see phone number and Fido address below).
  27.  
  28.  
  29. All of the sample programs use RKEY.TPU.  If you have Turbo Pascal (tm) 6.0,
  30. and need to use rKey6, simply change :
  31.  
  32.   Uses
  33.     rKey;
  34.  
  35. to
  36.  
  37.   Uses
  38.     rKey6;
  39.  
  40.  
  41. The various sample programs demonstrate the 2 methods of handling keys :
  42.  
  43.   Method 1 : Distribute your program (for example, RKSAMPLE.EXE) and use
  44.              a key file generation program (like RKGENFIL.EXE), which you
  45.              do NOT distribute, to create a key file for each user who
  46.              registers.  You then send the user the key file.
  47.  
  48.   Method 2 : Distribute your program (for example, RKSAMPLE.EXE) and a
  49.              branding program (like RKBRAND.EXE).  You then use a key
  50.              generation program (like RKGENKEY.EXE), which you do NOT
  51.              distribute, to create a a key number for each user who
  52.              registers.  You then send the user the key number, which
  53.              he/she enters into the brand program to create a key file.
  54.  
  55.  
  56. -------------------------------------------------------------------------------
  57.  
  58.  
  59. The following constants are defined in rKey :
  60.  
  61.   rKeyVersion = '1.5';         { contains the current version of rKey }
  62.  
  63.  
  64. The following variables are defined in rKey :
  65.  
  66.   OwnerCode   : String[20];
  67.   ProgramCode : String[16];
  68.   KeyFileName : String[8];
  69.   KeyFilePath : String[79];
  70.   RegError    : Boolean;
  71.   RegStatus   : Boolean;
  72.   RegName     : String[36];
  73.   RegKey      : String[12];
  74.  
  75.  
  76. The following procedures and functions are defined in rKey :
  77.  
  78.   Function MakeKey(Name : String) : String;
  79.   Function ValidKey(Name : String; Key : String) : Boolean;
  80.   Procedure GetRegInfo;
  81.   Procedure Register(Name : String; Key : String);
  82.  
  83.  
  84. -------------------------------------------------------------------------------
  85.  
  86.  
  87. OwnerCode : String[20];
  88.  
  89. This variable is NOT initialized by rKey and MUST be set at the start of your
  90. program.  It is used (along with ProgramCode) to generate the registration
  91. keys.  This variable should probably be the same for all software written by a
  92. single person/company.  Since is it used to cause your keys to be different
  93. from those of other programmers who are also using rKey, the more cryptic this
  94. variable is, the more secure your keys will be.
  95.  
  96.  
  97. Examples :
  98.  
  99.   OwnerCode := 'TrendSoft, Inc.';
  100.  
  101. {
  102.  If the name of your company is 'TrendSoft, Inc.', this is probably NOT a good
  103.  OwnerCode.  It would be easy for someone who knows the name of the company
  104.  to use the rKey unit to write a program that will generate keys for your
  105.  software.
  106. }
  107.  
  108.   OwnerCode := 'Trend&&Soft/Inc@';
  109.  
  110. {
  111.  This is better.  It still uses the name of the company, but it is somewhat
  112.  masked by the insertion of other characters and would be harder for another
  113.  programmer to guess.
  114. }
  115.  
  116.   OwnerCode := 'Read$Make@Into';
  117.  
  118. {
  119.  This is MUCH better.  It uses totally unrelated words that would be extremely
  120.  unlikely to be used by another programmer/company.
  121. }
  122.  
  123.   OwnerCode := 'EkQW3#m,-%\uSaXo^Ej7';
  124.  
  125. {
  126.  This is most likely the best, since it uses totally random symbols.
  127. }
  128.  
  129. IMPORTANT : You should NOT use any of the actual examples used here or in
  130.             the sample programs included with rKey.  If you do, anyone else
  131.             who uses the same example will have IDENTICAL keys!
  132.  
  133.  
  134. -------------------------------------------------------------------------------
  135.  
  136.  
  137. ProgramCode : String[16];
  138.  
  139. This variable is NOT initialized by rKey and MUST be set at the start of your
  140. program.  It is used (along with OwnerCode) to generate the registration keys.
  141. There are several approaches to the use of ProgramCode :
  142.  
  143.   (1) If ProgramCode is set to the same value for several programs
  144.       written by a person/company, keys for one piece of software will
  145.       work on another piece of software.  Using this approach, you
  146.       could have a single key for several programs.
  147.  
  148.   (2) If each program has a different ProgramCode and the ProgramCode is
  149.       not changed when the program changes, keys for one version of the
  150.       program will work for all versions of the same program.
  151.  
  152.   (3) If each program has a differenct ProgramCode and the ProgramCode is
  153.       changed when the program is changed, a different key will be
  154.       required for each version of the program.
  155.  
  156.  
  157. Examples :
  158.  
  159.   ProgramCode := 'RkStuff';
  160.  
  161. {
  162.  If you wrote a program called RkSample and a program called RkUtils and
  163.  you defined the ProgramCode as 'RkStuff' in both programs, a key for one
  164.  program would work for the other.
  165. }
  166.  
  167.   ProgramCode := 'RkSample';
  168.  
  169. {
  170.  If you wrote a program called RkSample and a program called RkUtils and
  171.  you defined the ProgramCode as 'RkSample' in RkSample and used a different
  172.  ProgramCode in RkUtils, a key for one would NOT work for the other.
  173. }
  174.  
  175.   ProgramCode := 'RkSample One';
  176.  
  177. {
  178.  If you wrote a program called RkSample and you defined the ProgramCode as
  179.  'RkSample One' in versions 1.1, 1.2 and 1.3 and then changed the
  180.  ProgramCode to 'RkSample Two' for version 2.0, the same key would work for
  181.  versions 1.1, 1.2 and 1.3 but would NOT work for version 2.0.
  182. }
  183.  
  184.  
  185. -------------------------------------------------------------------------------
  186.  
  187.  
  188. KeyFileName : String[8];
  189.  
  190. This variable is NOT initialized by rKey and MUST be set at the start of your
  191. program.  It is the name of the keyfile that is read by GetRegInfo and written
  192. to by Register.  This will probably be the name of the program file.  The
  193. extension will be '.KEY'.
  194.  
  195.  
  196. Examples :
  197.  
  198.   KeyFileName := 'RKSAMPLE';
  199.  
  200. {
  201.  The key file will be 'RKSAMPLE.KEY'.  Key files are always created and read
  202.  from the same directory that the program is in.  This is true even if the
  203.  program is not in the current directory.
  204. }
  205.  
  206.  
  207. -------------------------------------------------------------------------------
  208.  
  209.  
  210. KeyFilePath : String[79];
  211.  
  212. This variable is initialized by rKey to ''.  GetRegInfo and Register will set
  213. KeyFilePath to the full directory, filename and extension of the key file.  If
  214. no key file was found, KeyFilePath will be set to ''.
  215.  
  216.  
  217. Examples :
  218.  
  219.   KeyFileName := 'RKSAMPLE';
  220.   GetRegInfo;
  221.   If KeyFilePath <> '' then
  222.     WriteLn('Key file is ' + KeyFilePath);
  223.  
  224. {
  225.  The key file will be 'RKSAMPLE.KEY'.  After GetRegInfo is called, KeyFilePath
  226.  will contain the full pathname of the the key file, which is displayed (if it
  227.  is not '').
  228. }
  229.  
  230.  
  231. -------------------------------------------------------------------------------
  232.  
  233.  
  234. RegError : Boolean;
  235.  
  236. This variable is initialized by rKey to FALSE.  It is set by GetRegInfo and
  237. Register to indicate an invalid key.  If RegError is TRUE after a call to
  238. GetRegInfo, it means that the key contained in the key file is invalid.  This
  239. probably means that the key file has been tampered with.  If RegError is set
  240. to TRUE after a call to Register, it means that the key that was passed to
  241. Register was invalid or the program was unable to create the key file; and the
  242. key file was NOT written.
  243.  
  244.  
  245. Examples :
  246.  
  247.   KeyFileName := 'RKDEMO';
  248.   GetRegInfo;
  249.   If RegError then
  250.     WriteLn('The key file has been altered!');
  251.  
  252. {
  253.  This will call GetRegInfo.  If the key contained in 'RKDEMO.KEY' is invalid,
  254.  the message 'The KEY file has been altered!' will be displayed.
  255. }
  256.  
  257.  
  258. -------------------------------------------------------------------------------
  259.  
  260.  
  261. RegStatus : Boolean;
  262.  
  263. This variable is initialized by rKey to FALSE.  It is set by GetRegInfo and
  264. Register to indicate the software is registered.  If RegStatus is TRUE then
  265. RegName and RegKey contain valid registration information.  If RegStatus is
  266. FALSE (after a call to GetRegInfo), the software is unregistered.
  267.  
  268.  
  269. Examples :
  270.  
  271.   KeyFileName := 'RKDEMO';
  272.   GetRegInfo;
  273.   Write('RkDemo v1.5');
  274.   If RegError then
  275.     WriteLn('[invalid key]')
  276.   Else If RegStatus then
  277.     WriteLn('[registered]')
  278.   Else
  279.     WriteLn('[unregistered]');
  280.  
  281. {
  282.  This will call GetRegInfo.  If the key contained in 'RKDEMO.KEY' is invalid,
  283.  the message 'RkDemo v1.5 [invalid key]' will be displayed.  If the program
  284.  is registered, the message 'RkDemo v1.5 [registered]' will be displayed.
  285.  Otherwise, the message 'RkDemo v1.5 [unregistered]' will be displayed.
  286. }
  287.  
  288.  
  289. -------------------------------------------------------------------------------
  290.  
  291.  
  292. RegName : String[36];
  293.  
  294. This variable is initialized by rKey to ''.  It is set by GetRegInfo and
  295. Register if the software is registered.  This variable only contains valid
  296. information if RegStatus is TRUE.
  297.  
  298.  
  299. Examples :
  300.  
  301.   KeyFileName := 'RKDEMO';
  302.   GetRegInfo;
  303.   Write('RkDemo v1.5');
  304.   If RegError then
  305.     WriteLn('[invalid key]')
  306.   Else If RegStatus then
  307.     WriteLn('[registered to ' + RegName + ']')
  308.   Else
  309.     WriteLn('[unregistered]');
  310.  
  311. {
  312.  This will call GetRegInfo.  If the key contained in 'RKDEMO.KEY' is invalid,
  313.  the message 'RkDemo v1.5 [invalid key]' will be displayed.  If the program
  314.  is registered, the message 'RkDemo v1.5 [registered to NAME]' will be displayed
  315.  (with 'NAME' replaced by the name of the person that the software is
  316.  registered to).  Otherwise, the message 'RkDemo v1.5 [unregistered]' will be
  317.  displayed.
  318. }
  319.  
  320.  
  321. -------------------------------------------------------------------------------
  322.  
  323.  
  324. RegKey : String[12];
  325.  
  326. This variable is initialized by rKey to '000000000000'.  It is set by
  327. GetRegInfo and Register if the software is registered.  This variable only
  328. contains valid information if RegStatus is TRUE.  This contains the
  329. 12 digit hexadecimal registration key as a string.
  330.  
  331.  
  332. Examples :
  333.  
  334.   KeyFileName := 'RKMORE';
  335.   GetRegInfo;
  336.   If RegError or Not RegStatus then Begin
  337.     WriteLn('This version of RkMore is not registered.');
  338.     WriteLn('Please read the READ.ME file for more info.');
  339.   End Else
  340.     WriteLn('This version of RkMore is registered to ' + RegName + '.');
  341.     WriteLn('Registration key is ' + RegKey + '.');
  342.   End;
  343.  
  344. {
  345.  This will call GetRegInfo.  If the key contained in 'RKMORE.KEY' is invalid
  346.  or the program is not registered, a message will be displayed telling the
  347.  user how to register the program.  Otherwise, the name of the person that
  348.  that the program is registered to and the registration key will be
  349.  displayed.
  350. }
  351.  
  352.  
  353. -------------------------------------------------------------------------------
  354.  
  355.  
  356. Function MakeKey(Name : String) : String;
  357.  
  358. The function MakeKey will return a string containing the 12 digit hexadecimal
  359. registration key for the Name passed to it (using the pre-defined values of
  360. OwnerCode and ProgramCode). This function is usually used to create
  361. registration keys or key files, in a program that is not distributed to the
  362. user.
  363.  
  364.  
  365. Examples :
  366.  
  367.   OwnerCode := 'AZ771N91P03DJSS447';
  368.   ProgramCode := 'RkProg';
  369.   WriteLn('Registration Key Maker for RkProg');
  370.   WriteLn;
  371.   WriteLn('FOR INTERNAL USE ONLY!');
  372.   WriteLn;
  373.   Write('Enter name : ');
  374.   ReadLn(n);
  375.   k := MakeKey(n);
  376.   WriteLn;
  377.   WriteLn('Registration key is '+k);
  378.  
  379. {
  380.  This will display a warning message and then prompt for a name.  MakeKey is
  381.  then passed the name and then returns the key in the variable k, which is then
  382.  displayed.
  383. }
  384.  
  385.  
  386. -------------------------------------------------------------------------------
  387.  
  388.  
  389. Function ValidKey(Name : String; Key : String) : Boolean;
  390.  
  391. ValidKey will return TRUE, if Key is valid for the name passed to it (using the
  392. pre-defined values of OwnerCode and ProgramCode). If ValidKey returns FALSE,
  393. the key is not valid.
  394.  
  395.  
  396. Examples :
  397.  
  398.   OwnerCode := 'dfk89ew32zg0imm02';
  399.   ProgramCode := 'RkProg One';
  400.   WriteLn('RkProg v1.5');
  401.   WriteLn;
  402.   Write('Enter your name : ');
  403.   ReadLn(n);
  404.   Write('Enter your registration key : ');
  405.   ReadLn(k);
  406.   If Not ValidKey(n,k) then Begin
  407.     WriteLn('Invalid key!');
  408.     Halt(1);
  409.   End;
  410.  
  411. {
  412.  This program will prompt the user to enter a name and a registration key.
  413.  If the registration key is not valid, the program will display 'Invalid key!'
  414.  and Halt with an errorlevel of 1.
  415. }
  416.  
  417.  
  418. -------------------------------------------------------------------------------
  419.  
  420.  
  421. Procedure GetRegInfo;
  422.  
  423. GetRegInfo will read the key file (if it exists) and set the value of the
  424. following variables :
  425.  
  426.   RegError    { set to TRUE if the key file contains an invalid key }
  427.   RegStatus   { set to TRUE if the software is registered }
  428.   RegName     { set to the name of the person the software is registered to }
  429.   RegKey      { set to the 12 digit hexadecimal registration key }
  430.  
  431. GetRegInfo would generally be called near the beginning of a program (after
  432. OwnerCode, ProgramCode and KeyFileName are defined).
  433.  
  434.  
  435. Examples :
  436.  
  437.   OwnerCode := '&,<;(##@["+|~~**=#))';
  438.   ProgramCode := 'RkTest';
  439.   KeyFileName := 'RKTEST';
  440.   GetRegInfo;
  441.   If Not RegError then
  442.     If RegStatus then
  443.       WriteLn('Registered to ' + RegName);
  444.  
  445. {
  446.  GetRegInfo will read 'RKTEST.KEY'.  If it contains an invalid key, RegError
  447.  will be set.  If it doesn't exist, RegStatus will be set to FALSE.  Otherwise,
  448.  The various registration variables will be set.  The program then displays
  449.  the name of the person that the program is registered to.
  450. }
  451.  
  452.  
  453. -------------------------------------------------------------------------------
  454.  
  455.  
  456. Procedure Register(Name : String; Key : String);
  457.  
  458. Register will update the key file (creating it, if it doesn't exist) and set
  459. the value of the following variables :
  460.  
  461.   RegError    { set to TRUE if the Key parameter is invalid }
  462.               { or the file can NOT be created              }
  463.   RegStatus   { set to TRUE }
  464.   RegName     { set to the Name parameter }
  465.   RegKey      { set to the Key parameter }
  466.  
  467. If the Key parameter is invalid, RegError will be set to TRUE, the key file
  468. will NOT be written and the values of the other registration variables will
  469. NOT be changed.  Register would generally be called by an install or branding
  470. program of some type.  It can also be used by a key creation program, which
  471. is not distributed (if you want to send key files to registered users, rather
  472. than a key that they would enter).
  473.  
  474.  
  475. Examples :
  476.  
  477.   OwnerCode := 'Keyboard*Sytem=Load';
  478.   ProgramCode := 'RkProg';
  479.   KeyFileName := 'RKPROG';
  480.   WriteLn('RkProg Install Program');
  481.   WriteLn;
  482.   Write('Enter your name : ');
  483.   ReadLn(n);
  484.   Write('Enter your registration key : ');
  485.   ReadLn(k);
  486.   Register(n,k);
  487.   If RegError then
  488.     WriteLn('Invalid Key.  Program not installed.');
  489.  
  490. {
  491.  This program will prompt the user for a name and a registration key.  Register
  492.  will then be passed the name and the key.  If RegError is TRUE, the key was
  493.  invalid and no key file was written (the program displays 'Invalid Key.
  494.  Program not installed.').  Otherwise, RKPROG.KEY is written and the
  495.  registration variables are set.
  496. }
  497.  
  498.  
  499. -------------------------------------------------------------------------------
  500.  
  501.  
  502. For more information on using rKey, see the sample Turbo Pascal (tm) programs
  503. that are distributed with rKey, or contact me at any of the locations listed
  504. below.
  505.  
  506.  
  507. -------------------------------------------------------------------------------
  508.  
  509.  
  510. rKey is shareware. You may copy and distribute RKEY15.ZIP freely.  All I ask is
  511. that you include all of the original files, unmodified, and that you do not
  512. charge for the distribution of rKey itself.  You may use rKey for development
  513. of programs for your own use, to give away or to sell.
  514.  
  515.  
  516. If you like rKey and use it to develop software, a registration fee of $10
  517. or more toward the continued development of this unit and others like it
  518. would be appreciated.  See REGISTER.FRM for registration information.
  519.  
  520.  
  521. Everyone registering rKey with a registration fee of $10 or more, will be
  522. entitled to have one piece of software (written using rKey/RkPlus) listed,
  523. along with an address or phone number, in an application list that will be
  524. included with all future versions of rKey/RkPlus.  Registrations of $20 or
  525. more, will register both rKey AND RkPlus (available as RKPLUS21.ZIP), allowing
  526. you to develop and distribute programs using either one, or both. Registrations
  527. in excess of $20 will allow multiple applications to be listed.
  528.  
  529.  
  530. There are no royalties for the distribution of programs that are written
  531. with rKey.  A single registration fee entitles you to write and distribute
  532. any number of programs using rKey.
  533.  
  534.  
  535. If you have written an application using rKey/RkPlus, and wish to have it
  536. listed in the APPLIST.TXT file that is distributed with rKey/RkPlus, please
  537. send the following information via E/Mail, NetMail or US Mail :
  538.  
  539.   Name of Application
  540.   Programmer's Name (optional)
  541.   Copyright Notice
  542.   Address or Phone Number
  543.   System Requirements
  544.   Cost of Program (optional)
  545.   Any Additional Information (optional)
  546.  
  547.  
  548. Questions, comments, and suggestions are welcome.
  549.  
  550. Send E/Mail to   Scott Davis
  551.                  Phoenix StarFighter BBS [3/12/24/HST)
  552.                  Phone (404) 869-3410
  553.                  FidoNet Node 1:3616/20
  554.  
  555. Send US Mail to  Scott Davis
  556.                  Rt. 2 Box 95
  557.                  County Line Drive
  558.                  Lula, GA 30554
  559.  
  560.  
  561. We have the following "magic" filenames set up for FidoNet file requests :
  562.  
  563.   RKPLUS    will request the latest version of RkPlus
  564.   RKEY      will request the latest version of rKey
  565.  
  566.  
  567. -------------------------------------------------------------------------------
  568.  
  569.  
  570. I'd like to thank Danny Sosebee (Sysop of Phoenix StarFighter BBS) for
  571. allowing me to use his BBS as a way to receive suggestions and comments
  572. regarding rKey.  Also, I'd like to thank Ed Ivey (Sysop of Ed's Place
  573. BBS - 404/532-1978 - FidoNet Node 1:3616/1) for his continued support
  574. and assistance in distributing my little software "projects".
  575.  
  576.  
  577. -------------------------------------------------------------------------------
  578.  
  579.  
  580.       Turbo Pascal (tm) units available from Serious Cybernetics :
  581.  
  582.           StrLib 1.2          TP 5.5 String Functions Library Unit
  583.           rKey 1.5            TP 5.5/6.0 Registration Key Unit
  584.           RkPlus 2.1          TP 5.5/6.0 Registration Key Unit (enhanced)
  585.  
  586.  
  587. ------------------------------------------------------------------------------
  588.  
  589. RkPlus (c) 1991 Serious Cybernetics
  590. rKey, StrLib (c) 1990, 1991 Serious Cybernetics
  591. Turbo Pascal (c) 1983, 1989 Borland International
  592.  
  593.  
  594.